package com.dyw.democonsumer.controller;

import com.dyw.demoapi.entity.MailUser;
import com.dyw.demoapi.service.MailUserService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.cuit.epoch.result.Result;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Devil
 * @create 2022-03-05 15:01
 */
@RestController
@RequestMapping("user")
public class UserController {
    @DubboReference
    MailUserService mailUserService;

    @GetMapping
    public Result<List<MailUser>> selectUserList() {
        return mailUserService.selectUserList();
    }

    @PostMapping
    public Result<MailUser> addUser(@RequestBody MailUser mailUser) {
        return mailUserService.save(mailUser);
    }

    @GetMapping("/{id}")
    public Result<MailUser> selectUserById(@PathVariable("id") Integer id) {
        return mailUserService.selectUserById(id);
    }
}
